<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <!-- 利用管道，将timestampe进行格式化 -->
    {{timestampe | fmtTime}}
    <div :title="title | fmtTitle">过滤器v-bind测试</div>
  </div>
  <script>
    // 1.过滤器声明
    let fmtTime = (time) => {
      return new Date(time).toLocaleString()
    }
    // 2.全局注册过滤器
    Vue.filter('fmtTime',fmtTime)
    let vm = new Vue({
      el: '#app',
      data: {
        timestampe: 1622182782011,
        title: 'hello filter'
      },
      // 局部注册过滤器
      filters: {
        fmtTitle(title){
          return title.toUpperCase()
        }
      }
    })
  </script>
</body>
</html>